package com.iap.common.command
{
	import com.iap.common.service.IFavoriteService;
	import com.iap.common.signal.FavoriteRequestSignal;
	import com.iap.common.model.Favorite;
	
	import org.robotlegs.mvcs.SignalCommand;

	public class FavoriteCommand extends SignalCommand
	{
		[Inject]
		public var service:IFavoriteService;
		[Inject]
		public var model:Favorite;
		[Inject]
		public var task:String;

		override public function execute():void
		{
			service.task = task;
			switch(task)
			{
				case FavoriteRequestSignal.GET:
				{
					service.getList();
					break;
				}
				case FavoriteRequestSignal.SAVE:
				{
					service.save(model);
					break;
				}
				case FavoriteRequestSignal.DELETE:
				{
					service.remove(model);
					break;
				}
			}
		}
	}
}